-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement a MultiSelectionComboBox #4006
Implement a MultiSelectionComboBox #4006
Conversation
This comment has been minimized.
This comment has been minimized.
917d53f
to
81822a5
Compare
This comment has been minimized.
This comment has been minimized.
I don't think there is any need for those right now, but they can always be added later. RN I would go with your current implementation and see how well it works out. |
This comment has been minimized.
This comment has been minimized.
@timunie TBH what I need is a tool where I can put a list of all choices and get out a list of the ones user ticked. As long as that can be done I am fine with whatever way you achieved it. |
Hi @Luk164 , @punker76 , @ExLuzZziVo and anyone else interested: For my usecase I am now quite happy with the control. I would be very happy to get your feedback as well. You can try the control if you clone my branch and run the DemoApp. MultiSelectionComboBox_Example.mp4@punker76 I will update the Codacy-issues later. Also I want to wait until #4009 from @batzen is merged. Happy coding and a great weekend all of you |
9303b1c
to
6665884
Compare
There is a new issue which we should remember to add to the documentation: timunie/TimsWpfControls#14 (comment) Thank you @GWawrzeniecki for finding this. @punker76 maybe you have an idea if we can load to the |
b0bc35f
to
443746f
Compare
443746f
to
6f29024
Compare
24c1e74
to
f61171c
Compare
f61171c
to
8c2ccf3
Compare
Instead of having the |
This comment has been minimized.
This comment has been minimized.
Even though I don't think any user would notice some more milliseconds during the conversion of the new item he typed (so the performance aspect of this code is kind of irrelevant IMHO), using this implementation would also allow removing the Anyways, my approach here is to make the MSC (MultiSelectionComboBox) lighter for the developper who'll use it and to do things using the standard ways in order to reduce their code duplication. It may not be the best example but imagine someone wants to use your MSC with some You proposed providing a built-in PS : I'm not that familiar with Github, are we in the good place to discuss this? |
This comment has been minimized.
This comment has been minimized.
@timunie Wow, you did quite some work on this. I really hope this gets released soon. |
Below is a list of still open points
@punker76 I could need some help / guide regarding these issues
|
e19b195
to
658c099
Compare
I played around with the control and have some feedback:
|
Hi @FroggieFrog thank you for your feedback. Below please find some thoughts from my side:
Yes, I was also thinking of an option like this, but I want more. Maybe filtering, sorting, select all, select none, invert selection, add new item, what ever you can think of. So my idea is to add two Then you can apply your style, your controls and your functions you like. Should not be too hard I guess. Let me know if this is a way for you as well.
I think this is not how a normal // THE FOLLOWING CODE IS NOT PRODUCTION READY AND SHOULD ONLY SHOW THE BASIC CONECPT.
// Register to the loaded event of your MSCB
private void mscb_Example_Loaded(object sender, System.Windows.RoutedEventArgs e)
{
if (sender is MultiSelectionComboBox multiSelectionComboBox)
{
multiSelectionComboBox.ApplyTemplate(); // Make sure the Template is loaded.
if (multiSelectionComboBox.FindChild<TextBox>("PART_EditableTextBox") is TextBox textBox) // Get the TextBox
{
textBox.GotFocus -= TextBox_GotFocus;
textBox.GotFocus += TextBox_GotFocus;
}
}
}
// Do the opening here.
private void TextBox_GotFocus(object sender, System.Windows.RoutedEventArgs e)
{
if (mscb_Example.IsReadOnly && mscb_Example.IsEditable)
{
mscb_Example.SetCurrentValue(ComboBox.IsDropDownOpenProperty, true);
e.Handled = true;
}
} Happy coding |
aff5bf1
to
ddf9ea9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, but I feel like we should add some automated tests later on, to make sure everything keeps working.
18ec30b
to
baf6970
Compare
baf6970
to
87bf90f
Compare
- Add ToString() for the sample data - ClearTextButton - AutoWatermark
- Ability to use custom PanelTemplate - Add SelectedItemContainerStyle - Add ScrollViewer Update selection based on user defined text - Add `IObjectToStringComparer`- Interface to detect the matching objects. - Add possibility to control the `StringComparision`
to the `ItemsSource` (only if it implements `IList`. Note: The user needs to implement the interface on his own as there are so many different use cases possible. We have an example implementation in the demo App.
- Add more options for Styling and use it with DataTemplate - Added RightToLeft-Support - Add SelectedItemStringFormat so one can set different formats for the Popup and the SelectedItem - Respect SelectedItemStringFormat for the editable text as well - Additionally update the `Text`when `SelecteItemStringFormat` or `Separator` changes.
This attached property was missing here, so the horizontal scrolling was not possible.
- Implement `mah:ScrollViewerHelper.IsHorizontalScrollWheelEnabled` to control weather the selection should be changed via mouse wheel or not. - Also attachable to normal `ComboBox` - Override `PreviewMouseWheel` to prevent selection change if wanted and scroll the content instead - Selection via mouse wheel can only work if the selection mode is `Single`.
Additionally make these minor improvements - make Command fully static - restore selection after clear text - better check if ItemsSource is in use (PopupListBox) Changes from review
- We need to override the `SelectedIndex` and `SelectedItem` because the normal `ComboBox` behaves differently here. Remove not needed for-loop
It uses internally a `TypeConverter` to convert the string to the given `Type`.
- new AddingItemEvent - new AddedItemEvent - Fix typos - less user disturbtion Improve Selection from MouseWheel and Keyboard - only allow those selections when in `SelectionMode.Single` - Let the developer choose if this kind of selection is allowed - Enable Binding to SelectedItems - Fix MultiSelectorHelper - Do not crash if new value is null. Instead do not apply the Binding
With this change the user can implement quite easy a select all /select none button or other header or footer content
87bf90f
to
4807b02
Compare
@timunie your changes have been merged, thanks for your contribution 👍 |
Describe the changes you have made to improve this project
Added a
MultiSelectionComboBox
- Control which can be used to let the user select several items.Separator
SelectionMode
like in aListBox
Unit test
None
Additional context
See also #4000 and #3802
See it in Action
Please give me any feedback on this control.
Closed Issues
Closes #3802